<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateGroupsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('groups', function (Blueprint $table) {
            $table->unsignedBigInteger('id')->primary();
            $table->string('cover',255)->nullable()->default('')->comment('封面');
            $table->string('name',255)->default('')->comment('名称');
            // 设备分组 分润员工分组
            $table->enum('cate',['DEVICE','STAFF'])->default('DEVICE')->comment('群组类型');
            //ID 默认可以为空 分成为20%
            $table->unsignedBigInteger('policy_id')->nullable()->default(0)->comment('分成策略');
            $table->unsignedBigInteger('user_id')->default(0)->comment('创建人')->index('author');
            $table->integer('people_total')->default(0)->comment('成员总数');
            $table->enum('dividend_cate',['DEFAULT','CUSTOM'])->default('DEFAULT')->comment('分成类型');
            //  按10000计;
            $table->integer('dividend_scale')->default(8000)->comment('分成比例');
            //仅分润员工分组时
            $table->unsignedBigInteger('device_group_id')->nullable()->default(0)->comment('设备分组')->index('device_group');
            $table->timestamps();
            $table->softDeletes();
            $table->charset = 'utf8mb4';
            $table->collation = 'utf8mb4_unicode_ci';
            $table->engine = 'InnoDB';
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('groups');
    }
}
